﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SharpSoft.WPF
{
    /// <summary>
    /// InputDialog.xaml 的交互逻辑
    /// </summary>
    public partial class InputDialog : Window
    {
        public InputDialog()
        {
            InitializeComponent();
        }


        public string Text { get { return txt.Text; } set { txt.Text = value; } }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        public static string Dialog(Window owner, string title = "输入", string defstr = "")
        {
            InputDialog dlg = new InputDialog();
            dlg.Owner = owner;
            dlg.Text = defstr;
            dlg.Title = title;
            var result = dlg.ShowDialog();
            if (result.HasValue && result.Value)
            {
                return dlg.Text;
            }
            return null;
        }
    }
}
